Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR addresses the issue FSSDK-11494 by updating types for UserAttributes to support control attributes and by refactoring references to control attribute constants.
- Removed the FORCED_DECISION_NULL_RULE_KEY entry from CONTROL_ATTRIBUTES and introduced a new constant.
- Updated UserAttributeValue union to include undefined and ExperimentBucketMap, and updated tests and type usages accordingly.
- Modified buildVisitorAttributes to early exit on object types, which may affect processing of ExperimentBucketMap values.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| lib/utils/enums/index.ts | Removed FORCED_DECISION_NULL_RULE_KEY from control attributes. |
| lib/shared_types.ts | Updated UserAttributeValue type and UserAttributes structure. |
| lib/optimizely_user_context/index.ts | Replaced usage of CONTROL_ATTRIBUTES.FORCED_DECISION_NULL_RULE_KEY with new constant. |
| lib/optimizely_user_context/index.tests.js | Updated tests to reference the new forced decision key constant. |
| lib/event_processor/event_builder/user_event.ts | Modified buildVisitorAttributes to add an early return for object types. |
| lib/event_processor/event_builder/log_event.ts | Updated BOT_FILTERING key reference using CONTROL_ATTRIBUTES. |
| lib/core/decision_service/index.spec.ts | Updated test attribute types to use UserAttributes. |
junaed-optimizely
requested changes
May 6, 2025
There was a problem hiding this comment.
Pull Request Overview
Fixes the UserAttributes type to support control attributes by updating type definitions and replacing references to the forced decision key constant.
- Removed FORCED_DECISION_NULL_RULE_KEY from CONTROL_ATTRIBUTES and replaced its usage with the standalone constant.
- Extended UserAttributeValue to include undefined and ExperimentBucketMap.
- Updated the user context, tests, and attribute building logic to align with the new types.
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| lib/utils/enums/index.ts | Removed FORCED_DECISION_NULL_RULE_KEY from CONTROL_ATTRIBUTES. |
| lib/shared_types.ts | Updated UserAttributeValue type and made control attribute keys optional. |
| lib/optimizely_user_context/index.ts | Replaced references from CONTROL_ATTRIBUTES to the new constant. |
| lib/optimizely_user_context/index.tests.js | Updated tests to use the new forced decision key constant. |
| lib/event_processor/event_builder/user_event.ts | Refactored buildVisitorAttributes for clearer attribute handling. |
| lib/event_processor/event_builder/log_event.ts | Adjusted BOT_FILTERING attribute to use CONTROL_ATTRIBUTES constant. |
| lib/core/decision_service/index.spec.ts | Updated test attribute types to UserAttributes for consistency. |
Comments suppressed due to low confidence (2)
lib/shared_types.ts:75
- Ensure that 'ExperimentBucketMap' is declared or properly imported; its inclusion in the union type may lead to unexpected type conflicts if not defined.
export type UserAttributeValue = string | number | boolean | null | undefined | ExperimentBucketMap;
lib/event_processor/event_builder/user_event.ts:266
- [nitpick] Verify that excluding attribute values of type 'object' does not omit valid attribute data (e.g., arrays) that should be logged, in accordance with log endpoint requirements.
if (typeof attributeValue === 'object' || typeof attributeValue === 'undefined') {
junaed-optimizely
approved these changes
May 6, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Test plan
Issues